import View from './view';
import Form from './form';
import { getValidate } from '../utils';

import type { Rules } from 'async-validator/dist-types/interface';

export const rules: Rules = {
  borderRadius: [
    {
      type: 'number',
      required: true,
      message: '图片圆角不能为空',
    },
    {
      type: 'number',
      min: 0,
      message: '图片圆角不能小于0',
    },
  ],
};

export const DISPLAY_SET = {
  line: {
    value: 'line',
    label: '有描边',
  },
  button: {
    value: 'button',
    label: '有按钮',
  },
};

// initialValues分为content内容和样式，所有组件都包含两者，所以应该提到一个公共文件中去
const initialValues = {
  searchText: '搜索热词',
  displaySetting: [DISPLAY_SET.line.value, DISPLAY_SET.button.value], // 是否有按钮 // 是否有描边
  borderRadius: 2, // 圆角值
  borderColor: 'white', // 描边颜色
  btnColor: '#fdb41a', // 按钮颜色
  bgColor: '#fdb41a', // 背景颜色
};

export type SearchValue = typeof initialValues;

export default {
  type: 'Search',
  title: '搜索',
  logo: 'https://saascdn.yumchina.com/crmyumc/768479403501420544/member/202308211334151380.jpg',
  initialValues,
  view: View,
  form: Form,
  limit: 1,
  validate: getValidate(rules),
};
